added asserts for a lot of stuff and tests