Various fixes and starting test cases