Kaplansky's density theorem proof I will assume familiarity with the statement, which can also be found here, and I will use the notation there too.  http://en.wikipedia.org/wiki/Kaplansky_density_theorem
I have a problem with the standard proof, when people claim that it works at this level of generality where A need not have the unit $1_H$ of B(H).  One usually proceeds first by reducing in the obvious way to where the $A$ is norm closed, and then to where we consider just the self adjoint elements  Then they pick some continuous function from R to R with the property that it smoothly interpolates between the limits at $\infty$ and $-\infty$ of $+1$ and $-1$ respectively.  For instance, one could use $f(t)=t/(t^2+1)$.  In the midst of this argument, one has to use that the functional calculus takes the self adjoints in $A$ to the self adjoints in $A$, because the point of this function is basically to squash your strongly approximating net to be within the unit ball of the self adjoint subspace of A.  This $f$ is a continuous function, so I may as well be talking about the continuous functional calculus as opposed to Borel, and then one observes that the continuous functional calculus relative to A is the same as relative to B(H) because the spectra coincide.  That is how one sees that when I compute $f(a)$ relative to $B(H)$ for $a$ in $A$ self adjoint, I still end up in $A$.  This all goes bad when $A$ doesn't contain $1_H$.
How can I understand why nevertheless, the statement is true at this level of generality?
 A: Spectra still coincide, even for nonunital C*-subalgebras.  If $A$ is nonunital, the $0$ is in the spectrum of every element of $A$, and in order to apply continuous functional calculus to self-adjoint (or normal) elements of $A$, you just have to be sure that your continuous $f$ satisfies $f(0)=0$ (elaborated below), as the example you gave does.  
If $A$ is a nonunital C*-subalgebra of $B(H)$, then the unitization of $A$ is (isomorphic to) $\tilde A=A+\mathbb C I_H$.  If $a$ is a self-adjoint element of $A$, then $C^*(a,I_H)\cong C(\sigma(a))$ under the Gelfand map, and this isomorphism sends $C^*(a)$ to the maximal ideal $\{f\in C(\sigma(a)):f(0)=0\}$.  Hence if $f:\mathbb R\to\mathbb R$ is continuous and $f(0)=0$, then $f(a)$ is in $C^*(a)\subseteq A$, and not just in the unital algebra $\tilde A$.
A more concrete way to see that $f(0)=0$ implies that $f(a)$ is in $A$ is to note that every continuous function $f$ on $\sigma(a)$ such that $f(0)=0$ can be uniformly approximated by polynomials of the form $p(x)=a_1x+a_2x^2+\cdots+a_nx^n$, by the Weierstrass approximation theorem, and therefore $f(a)$ is a limit of elements of the form $p(a)\in A$.  (Note that if $p_n\to f$ uniformly on $\sigma(a)$ and $p_n(0)$ is not necessarily $0$, you could take $p_n-p_n(0)$, which will still converge uniformly to $f$.)
