added assert()s
added tests