Resolves #18. Also increased test coverage