added more tests; fixed edge case