Unit Test and bug fix LazyLoader

Unit tests have been written for the lazy loader and some issues encountered while testing fixed.