fixes issue with singletons
adds tests