fixed some whitespace related bugs; added tests; typo