added unit test and fixed stupid error