Added test cases, fixed bugs around classloading