added tests and test support, fixed critical callback bugs, initialization