Implemented proper spacing handling and related test coverage