How does a transistor work when collector is disconnected?
Yep, it works. 

The base to emitter connection with collector floating is in fact just a diode. You're downgrading a NPN transistor to a PN junction in your case. You won't get the current amplification feature of the transistor because you've not connected the collector.

In this configuration you have a silicon PN junction and it does all what a PN junction does: rectification, about 0.7v voltage drop and so on. It's not much different to what a vanilla diode like the common 1N4184 diode would do. On the other hand diodes are optimized to do the diode job while a base-emitter junction is not, so you'll likely get better performance from a dedicated diode.