Improves tests, formatting, error handling